package com.greydawn.MementoPattern.gameExp;

/**
 * @Author: zhongwr
 * @Create: 2021/12/19 14:55
 * @Version 1.0
 * @Description: 显式使用状态
 */
public class GameRole {

    /**
     * 生命值
     */
    private int lifeValue;
    /**
     * 魔法值
     */
    private int magicValue;
    /**
     * 攻击值
     */
    private int attackValue;
    /**
     * 血瓶 血瓶数量不可备份，用完就没了哦
     */
    private int redBottle;

    public int getLifeValue() {
        return lifeValue;
    }

    public void setLifeValue(int lifeValue) {
        this.lifeValue = lifeValue;
    }

    public int getMagicValue() {
        return magicValue;
    }

    public void setMagicValue(int magicValue) {
        this.magicValue = magicValue;
    }

    public int getAttackValue() {
        return attackValue;
    }

    public void setAttackValue(int attackValue) {
        this.attackValue = attackValue;
    }

    public int getRedBottle() {
        return redBottle;
    }

    public void setRedBottle(int redBottle) {
        this.redBottle = redBottle;
    }

    public GameRole(int lifeValue, int magicValue, int attackValue, int redBottle) {
        this.lifeValue = lifeValue;
        this.magicValue = magicValue;
        this.attackValue = attackValue;
        this.redBottle = redBottle;
    }

    public void recoverState(GameMemento gameMemento) {
        this.lifeValue = gameMemento.getLifeValue();
        this.magicValue = gameMemento.getMagicValue();
        this.attackValue = gameMemento.getAttackValue();
    }

    public GameMemento saveState() {
        return new GameMemento(lifeValue, magicValue, attackValue);
    }

    @Override
    public String toString() {
        return " 角色状态:" +
                "生命值=" + lifeValue +
                "魔法值=" + magicValue +
                "攻击值=" + attackValue +
                "血瓶=" + redBottle;
    }
}
